{
  "name": "Case 8 – Franchise Application Evaluation",
  "nodes": [
    {
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2,
      "position": [0, 0],
      "parameters": {
        "formTitle": "Franchise Application Submission",
        "formDescription": "Upload franchise business plan for evaluation",
        "formFields": {
          "values": [
            { "fieldLabel": "Applicant Name", "requiredField": true },
            { "fieldLabel": "Email id", "fieldType": "email", "requiredField": true },
            {
              "fieldLabel": "Business_Plan",
              "fieldType": "file",
              "acceptFileTypes": ".pdf",
              "requiredField": true
            }
          ]
        }
      }
    },
    {
      "name": "Upload file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [220, 0],
      "parameters": {
        "inputDataFieldName": "Business_Plan",
        "name": "={{ $json['Applicant Name'] + '_Franchise_Business_Plan' }}",
        "folderId": "REPLACE_WITH_FRANCHISE_APPLICATIONS_FOLDER_ID"
      }
    },
    {
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [420, 0],
      "parameters": {
        "operation": "download",
        "fileId": "={{ $json.id }}"
      }
    },
    {
      "name": "Extract Business Plan",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [620, 0],
      "parameters": {
        "operation": "pdf"
      }
    },
    {
      "name": "Download Franchise Evaluation Policy",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [820, 0],
      "parameters": {
        "operation": "download",
        "fileId": "REPLACE_WITH_FRANCHISE_POLICY_FILE_ID"
      }
    },
    {
      "name": "Extract Franchise Policy",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [1020, 0],
      "parameters": {
        "operation": "pdf"
      }
    },
    {
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [220, 260],
      "parameters": {
        "promptType": "define",
        "text": "=Applicant Business Plan:\n{{ $('Extract Business Plan').item.json.text }}\n\nFranchise Expansion & Evaluation Policy:\n{{ $('Extract Franchise Policy').item.json.text }}",
        "options": {
          "systemMessage": "You are the Head of Franchise Expansion for a multi-location consumer brand.\n\nYOUR OBJECTIVE:\nSelect franchise partners who can scale profitably while protecting brand standards and long-term unit economics.\n\nANALYSIS FRAMEWORK (MANDATORY):\n1. FINANCIAL CAPACITY – net worth, liquidity, ability to fund setup and sustain losses during ramp-up.\n2. OPERATIONAL EXPERIENCE – prior experience running multi-unit retail, QSR, or consumer businesses.\n3. TERRITORY POTENTIAL – demand density, competition, scalability of the proposed geography.\n4. EXECUTION RISK – manpower plan, timelines, vendor readiness, regulatory awareness.\n5. BRAND FIT – alignment with SOPs, quality standards, and growth philosophy.\n\nYOU MUST PRODUCE ONE JSON OBJECT WITH EXACTLY THESE FIELDS. ALL FIELDS ARE MANDATORY.\n\nJSON SCHEMA (STRICT):\n{\n  \"Applicant_Name\": \"string\",\n  \"Proposed_Territory\": \"string\",\n  \"Applicant_Net_Worth_INR_Cr\": \"number\",\n  \"Liquid_Capital_INR_Cr\": \"number\",\n  \"Relevant_Operating_Experience_Years\": \"number\",\n  \"Territory_Potential\": \"Low | Medium | High\",\n  \"Financial_Viability\": \"Weak | Moderate | Strong\",\n  \"Operational_Readiness\": \"Low | Medium | High\",\n  \"Overall_Franchise_Fit_Score_out_of_100\": \"number\",\n  \"Expansion_Decision\": \"Proceed to Territory Discussion | Reject\",\n  \"Key_Evaluation_Remarks\": \"string\"\n}\n\nINSTRUCTIONS:\n- Numeric fields MUST contain numbers only.\n- Do NOT add, remove, or rename fields.\n- Output ONLY valid JSON.\n- IMMEDIATELY call the Google Sheets Append Row tool using this JSON."
        }
      }
    },
    {
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [0, 420],
      "parameters": {
        "model": {
          "mode": "list",
          "value": "gpt-4.1-mini"
        }
      }
    },
    {
      "name": "Append row",
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4,
      "position": [420, 460],
      "parameters": {
        "operation": "append",
        "documentId": "REPLACE_WITH_GOOGLE_SHEET_ID",
        "sheetName": "Franchise Application Evaluation Register"
      }
    },
    {
      "name": "Send Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [420, 260],
      "parameters": {
        "sendTo": "={{ $('On form submission').item.json['Email id'] }}",
        "subject": "Franchise Application – Evaluation Outcome",
        "message": "={{ 'Dear ' + $('On form submission').item.json['Applicant Name'] + ',<br><br>Thank you for your interest in our franchise network. Your application has been reviewed by our expansion committee. We will contact you shortly regarding the next steps.<br><br>Franchise Expansion Team' }}"
      }
    }
  ],
  "connections": {
    "On form submission": { "main": [[{ "node": "Upload file" }]] },
    "Upload file": { "main": [[{ "node": "Download file" }]] },
    "Download file": { "main": [[{ "node": "Extract Business Plan" }]] },
    "Extract Business Plan": { "main": [[{ "node": "Download Franchise Evaluation Policy" }]] },
    "Download Franchise Evaluation Policy": { "main": [[{ "node": "Extract Franchise Policy" }]] },
    "Extract Franchise Policy": { "main": [[{ "node": "AI Agent" }]] },
    "OpenAI Chat Model": { "ai_languageModel": [[{ "node": "AI Agent" }]] },
    "Append row": { "ai_tool": [[{ "node": "AI Agent" }]] },
    "AI Agent": { "main": [[{ "node": "Send Email" }]] }
  },
  "active": false
}
